import Models

"""Implentations of the commands used in the mud.  These are called from Parser.dispatch"""

def cmd_go(**args):
   outputs = []
   player = args["player"]
   direction = args["identifier"]["identifier"]
   print "Going",direction
   
   try:
      #Move the player to the new room.
      originalroom = player.currentroom
      exit = Models.Link.selectBy(exit=player.currentroom,direction=direction).getOne()
      player.currentroom = exit.destination
      outputs.append( cmd_look(player=player)[0] )
   except:
      outputs.append("No such exit")
      
      #Notify players in the old room.
   return outputs

def cmd_look(**args):
   outputs = []
   player = args["player"]
   outputs.append( player.currentroom.describe() )
   return outputs

def cmd_unknown(**args):
   """Returned if the command is never going to be in the game."""
   return ["Command not known\n"]

def cmd_notimp(player,identifier):
   """Returned if the command is going to be in the game but hasn't been written yet."""
   return ["Not implemented\n"]
